package com.df.ez_game.server.logic.status_sync;

/**
 * 同步推送消息枚举类 - 定义状态同步所需的消息类型
 */
public enum SyncPushMsgEnum {
    // 移动消息
    Move(1, "move"),
    
    // 状态同步消息（批量同步玩家状态）
    StateSync(2, "stateSync"),
    
    // 玩家进入消息
    PlayerEnter(3, "playerEnter"),
    
    // 玩家离开消息
    PlayerLeave(4, "playerLeave"),
    
    // 进入地图响应消息
    EnterMapResp(5, "enterMapResp");
    
    private final int cmd;
    private final String name;
    
    SyncPushMsgEnum(int cmd, String name) {
        this.cmd = cmd;
        this.name = name;
    }
    
    public int getCmd() {
        return cmd;
    }
    
    public String getName() {
        return name;
    }
    
    /**
     * 根据命令号获取对应的枚举值
     */
    public static SyncPushMsgEnum getByCmd(int cmd) {
        for (SyncPushMsgEnum msgEnum : values()) {
            if (msgEnum.cmd == cmd) {
                return msgEnum;
            }
        }
        return null;
    }
    
    /**
     * 根据名称获取对应的枚举值
     */
    public static SyncPushMsgEnum getByName(String name) {
        for (SyncPushMsgEnum msgEnum : values()) {
            if (msgEnum.name.equals(name)) {
                return msgEnum;
            }
        }
        return null;
    }
}